/**
 * 项目名：	Rumba Plan
 * 
 * 版权所有(C)，上海海鼎信息工程股份有限公司，2006，所有权利保留。
 * 
 * 文件名：	ProcessUnloadCFV.java
 * 模块说明：	
 * 修改历史：
 * 2006-11-3 - lxm - 创建。
 */
package com.hd123.rumba.action.domain;

import net.sf.hibernate.HibernateException;

import com.hd123.rumba.cartridge.CCartFunctionView;
import com.hd123.rumba.cartridge.biz.BCartFunctionView;
import com.hd123.rumba.cartridge.biz.IBCartridgeMgr;
import com.hd123.rumba.domain.CDomain;
import com.hd123.rumba.domain.biz.IBDomainMgr;
import com.hd123.rumba.domain.biz.SDomain;
import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.runtime.NamingMgr;
import com.hd123.rumba.runtime.OperateContext;
import com.hd123.rumba.runtime.backprocess.BackProcess;

/**
 * 卸载域的构件包功能视图 | 后台处理过程
 * 
 * @author lxm
 * 
 */
public class ProcessUnloadCFV extends BackProcess {

  private String targetCFVUuid;
  private String domainUuid;
  private long domainOca;

  private String strCFV = CCartFunctionView.CAPTION_CLASS;
  private String strDomain = CDomain.CAPTION_CLASS;

  @Override
  public synchronized String getCaption() {
    return "卸载 " + strDomain + " 中的 " + strCFV + " ";
  }

  @Override
  public synchronized Object getPromptReceiver() {
    return this.getOperator();
  }

  @Override
  public void execute() throws BusinessException, HibernateException, InterruptedException {
    this.setDomain(this.getOperator().getDomain());
    IBDomainMgr bdmMgr = (IBDomainMgr) NamingMgr.getInstance().lookupMgr(IBDomainMgr.class);
    bdmMgr.unloadCFVsFromDomainT(targetCFVUuid, domainUuid, new OperateContext(this.getOperator()), domainOca);
  }

  public synchronized long getDomainOca() {
    return domainOca;
  }

  public synchronized void setDomainOca(long domainOca) {
    this.domainOca = domainOca;
  }

  public synchronized String getDomainUuid() {
    return domainUuid;
  }

  public synchronized void setDomainUuid(String domainUuid) {
    this.domainUuid = domainUuid;
    try {
      IBDomainMgr dmMgr = (IBDomainMgr) NamingMgr.getInstance().lookupMgr(IBDomainMgr.class);
      SDomain domain = dmMgr.getDomain(domainUuid);
      strDomain = domain.getNameCode();
    } catch (Exception e) {
    }
  }

  public synchronized String getTargetCFVUuid() {
    return targetCFVUuid;
  }

  public synchronized void setTargetCFVUuid(String targetCFVUuid) {
    this.targetCFVUuid = targetCFVUuid;
    try {
      IBCartridgeMgr cartMgr = (IBCartridgeMgr) NamingMgr.getInstance().lookupMgr(
          IBCartridgeMgr.class);
      BCartFunctionView cfv = cartMgr.getFunctionView(targetCFVUuid);
      strCFV = cfv.getGlobalCaption();
    } catch (Exception e) {
    }
  }

}
